package com.qt.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author pgw
 * @version 1.0
 * @description
 * @date Create by 2023/10/15 21:35
 */
public class FileUtil {


    /**
     * 判断某个工作目录是否存在
     *
     * @param filePath 需要读取的文件目录
     * @return 文件内容，以行代表数组的下标
     * @throws IOException an I/O exception
     * @author yuzhanglong
     * @date 2020-6-30 11:03:47
     */
    public static List<String> readFileByLines(String filePath) throws IOException {
        File file = new File(filePath);
        BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
        String tempStr;
        List<String> stringList = new ArrayList<>();
        while ((tempStr = bufferedReader.readLine()) != null) {
            stringList.add(tempStr);
        }
        return stringList;
    }
}
